package com.fkcai.hansoul.model.vo.post;

import com.fkcai.hansoul.model.entity.Post;
import com.fkcai.hansoul.model.entity.PostImage;
import com.fkcai.hansoul.model.entity.User;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 帖子基础响应信息 VO
 *
 * <p>
 * 该类用于封装后端向前端返回的帖子创建响应数据，将帖子创建后的相关信息封装为一个对象，
 * 便于前端接收和处理响应结果。
 * </p>
 *
 * @author 香辣鸡腿堡
 * @version 1.0.0
 * @since 2025-04-27
 */
@Data
@ToString
@Accessors(chain = true)
public class PostBaseInfoVo {
	private Integer postId;
	private String title;
	private String content;
	private LocalDateTime createTime;
	private Integer categoryId;    // 类别 id
	private Integer userId;
	private String postStatus;      // 帖子状态
	private String location;          // 位置
	
	private List<String> imageUrls; // 图片地址列表
	// private String videoUrl;    // 视频地址
	
	public static PostImage getImageUrls(PostImage postImage) {
		return postImage;
	}
	
	public static PostBaseInfoVo fromPost(Post post) {
		PostBaseInfoVo postBaseInfoVo = new PostBaseInfoVo();
		
		postBaseInfoVo.setPostId(post.getPostId());
		postBaseInfoVo.setTitle(post.getTitle());
		postBaseInfoVo.setContent(post.getContent());
		postBaseInfoVo.setCreateTime(post.getCreateTime());
		postBaseInfoVo.setCategoryId(post.getCategoryId());
		postBaseInfoVo.setUserId(post.getAuthorId());
		postBaseInfoVo.setPostStatus(post.getPostStatus());
		postBaseInfoVo.setLocation(post.getLocation());
		
		return postBaseInfoVo;
	}
}
